<?php

require_once 'plugins/Ssl.php';

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    public function __construct($application) {
        Zend_Session::start();
        parent::__construct($application);
    }

    protected function _initDoctype()
    {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
    }

    protected function _initAdminnav()
    {
        $this->bootstrap('View');
        $view = $this->getResource('View');

        $view->placeholder('adminnav');
    }

    protected function _initProdajanav()
    {
        $this->bootstrap('View');
        $view = $this->getResource('View');

        $view->placeholder('prodajanav');
    }
    
    protected function _initIzdelkinav()
    {
        $this->bootstrap('View');
        $view = $this->getResource('View');

        $view->placeholder('izdelkinav');
    }
    
    protected function _initStrankanav()
    {
        $this->bootstrap('View');
        $view = $this->getResource('View');

        $view->placeholder('strankanav');
    }
    
    protected function _initKosaricanav()
    {
        $this->bootstrap('View');
        $view = $this->getResource('View');

        $view->placeholder('kosaricanav');
    }


    protected function _initAutoload() {
        $autoloader = new Zend_Application_Module_Autoloader(
            array(
                'namespace' => 'Default_',
                'basePath' => dirname(__FILE__),
            )
        );
        return $autoloader;
    }

    protected function _initRestRoute() {
        $this->bootstrap('Request');
        $front = $this->getResource('FrontController');
        $restRoute = new Zend_Rest_Route($front, array(), array( 'default' => array('rest') ));
        $front->getRouter()->addRoute('rest', $restRoute);
    }

    protected function _initRequest() {
        $this->bootstrap('FrontController');
        $front = $this->getResource('FrontController');
        $request = $front->getRequest();
        if (null === $front->getRequest()) {
            $request = new Zend_Controller_Request_Http();
            $front->setRequest($request);
        }
        return $request;
    }

    protected function _initConfig()
    {
        $config = new Zend_Config($this->getOptions(), true);
        Zend_Registry::set('config', $config);
        return $config;
    }

    public function _initSsl() {
        $Zend_Controller_Front = $this->getResource('FrontController');
        $Zend_Controller_Front->registerPlugin( new Application_Plugins_Ssl() );
    }
}

